import { ThingSizeModel } from './base/model';

const radius = 6;
export class Ball {
    public ballHandler: PIXI.Graphics;
    public xDirect = -1;
    public yDirect = -1;
    constructor(private app: PIXI.Application) {
        this.ballHandler = this.createBall();

    }

    private createBall(): PIXI.Graphics {
        const graphics = new PIXI.Graphics();

        // Circle
        graphics.lineStyle(0); // draw a circle, set the lineStyle to zero so the circle doesn't have an outline
        graphics.beginFill(0xDE3249, 1);
        graphics.drawCircle(0, 0, radius);
        graphics.endFill();

        this.app.stage.addChild(graphics);
        graphics.position.x = this.app.view.width / 2;
        graphics.position.y = this.app.view.height - 30;
        return graphics;
    }

    public getBallOffset(x:number, y:number): ThingSizeModel {
        return new ThingSizeModel(x - radius, x + radius, y - radius, y + radius);
    }
}
